package cn.hncu_1;

import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;
//自己实现窗体关闭功能
public class Demo {
	public static void main(String []args)
	{
		JFrame f=new JFrame("时间处理");//窗口设置
		f.setSize(300,500);//大小设置
		f.setLocationRelativeTo(null);//窗口居中
//		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//给窗体增加一个监听
		f.addWindowListener(new myWindowListener());
		f.setVisible(true);//窗口可视化
	}
	
}
class myWindowListener implements WindowListener{


	@Override
	public void windowOpened(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowClosing(WindowEvent e) {
		// TODO Auto-generated method stub
		System.exit(0);
	}

	@Override
	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowIconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowDeiconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void windowDeactivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}
}
